<div class="prod_details">
    <?php // Vars: $product

    use_helper('AddToCart');
    echo _open('div.productthumb');

    echo _link($product)->set('.imgfl')->text(_media($product->Image)->size(182, 230));
    echo _close('div');
    echo _open('div.productinfo');
    echo _tag('div',_tag('label','Code').$product->item_code);
    echo _tag('div',_tag('label','Item').($product).' , '.$product->ProductCategory);
    echo markdown($product->description);

    echo _open('div');
    echo _tag('label','Available Size ');
    $sizes = array();
    foreach ($product->ProductSizeList as $size) {
        $sizes[] = $size->name;
    }
    sort($sizes);
    echo implode(', ', $sizes) ."  <a href='#size_gidue'>Size Gidue</a>";
    echo _close('div');
    echo _open('div');
    echo _tag('label','Available Color ');
    $colors = array();
    foreach ($product->ProductColorList as $color) {
        $colors[] = $color->name;
    }
    sort($colors);
    echo implode(', ', $colors) ."  <a href='#color_gidue'>Color Gidue</a>";
    echo _close('div');
//    echo _tag('div',_tag('label','Boady Length').$product->body_length);
//    echo _tag('div',_tag('label','Half Chest Width ').$product->half_chest_width);
    echo _tag('div',_tag('label','Price Rate ').$product->price);

    echo _tag('div',_tag('label','Free Gift ').$product->product_gift_id);


    echo _close('div');
    echo _open('div.addcartform');
    ?>
    <form onSubmit="" method="post" action="<?php echo _link('customarOrder/addToCart')->getHref()?>">
        <label for="order">Order : </label>

        <label for="size">size</label>
        <select name="size" id="size">
            <?php  foreach ($sizes as $size) :?>
            <option value="<?php echo $size?>"><?php echo $size?></option>
            <?php endforeach;?>
        </select>
        <label for="size">Color</label>
        <select name="color" id="size">
            <?php foreach ($colors as $color):?>
            <option value="<?php echo $color?>"><?php echo $color?></option>
            <?php endforeach;?>
        </select>
        <label for="qty">Qty</label>
        <input type="text" name="qty" id="qty">
        <input type="hidden" value="<?php echo $product->id?>" name="product_id">
        <input class="addcartsubmit" type="submit" id="button" value="Keep In Order Busket ">
    </form>
    <?php

    echo _close('div');
    echo _tag('div.clear');
// Vars: $product

// get a collection of medias related to the article, ordered by position
    $medias = $product->getDmGallery();

// get the number of medias related to the article
    $nbMedias = $product->getNbMedias();

// get the first media related to the article
    $firstMedia = $product->getFirstMedia();

// display all gallery medias
    foreach($product->getDmGallery() as $media) {
        echo _media($media)->set('.imgfl')->width(355);
    }

    echo _tag('div.clear');
    if(count($product->ProductDetailFields)) {
        echo _tag('h3.title',"<a name='size_gidue'>Product Size Gidue</a>");


        ?>
    <table cellspacing="0" cellpadding="0" border="1" style="border-collapse:collapse;border:medium none ; width: 100%">
        <thead>  <tr>
                <td   valign="top" style=" border:1pt solid windowtext;padding:0in 5.4pt" colspan="2">
                    <p class="MsoNormal"><b><span style="font-size:14pt"> </span></b></p>
                </td>
                    <?php

                    foreach ($product->ProductSizeList as $size) {
                        ?>
                <td   valign="top" style=" border-width:1pt 1pt 1pt medium;border-style:solid solid solid none;border-color:windowtext windowtext windowtext -moz-use-text-color;padding:0in 5.4pt">
                    <p class="MsoNormal"><b><span style="font-size:14pt"><?php echo $size; ?></span></b></p>
                </td>
                        <?php
                    }
                    ?>
            </tr>
        </thead>
        <tbody>
                <?php
                $marker = '';
                foreach ($product->ProductDetailFields as $detailField) {
                    list($type,$name)= explode(':',  $detailField->name);
                    if($marker != $type) {


                        ?>
            <tr>
                <td   valign="top" style=" border-width:medium 1pt 1pt;border-style:none solid solid;border-color:-moz-use-text-color windowtext windowtext;padding:0in 5.4pt">
                    <p class="MsoNormal"><span style="font-size:14pt"><?php echo $type ?></span></p>
                </td>
                <td   valign="top" style=" border-width:medium 1pt 1pt;border-style:none solid solid;border-color:-moz-use-text-color windowtext windowtext;padding:0in 5.4pt">
                    <p class="MsoNormal"><span style="font-size:14pt"><?php echo $name; ?></span></p>
                </td>
                            <?php
                            foreach ($product->RelatedProductSize as $size) {
                                ?>
                <td   valign="top" style=" border-width:1pt 1pt 1pt medium;border-style:solid solid solid none;border-color:windowtext windowtext windowtext -moz-use-text-color;padding:0in 5.4pt">
                    <p class="MsoNormal"><b><span style="font-size:14pt">
                                                <?php
                                                foreach ($product->ProductDetailFields as $detailField1) {
                                                    list($type1,$name1)= explode(':',  $detailField1->name);
                                                    if($type1 == $type) {
                                                        if( $detailField1->size_id == $size->size_id)
                                                            echo $detailField1->value;
                                                        else
                                                            echo '';
                                                    }
                                                }
                                                ?></span></b></p>
                </td>
                                <?php



                            }
                            ?>
                            <?php
                        }
                        $marker = $type;
                        ?>
            </tr>
                    <?php
                }

                ?>
        </tbody>
    </table>

        <?php
    }
    if(count($product->RelatedProductColor)) {
        echo _open('div.color_gidue');
        echo _tag('h3.title',"<a name='color_gidue'>Product Color Gidue</a>");

        foreach ($product->RelatedProductColor as $color) {
            echo _open('div.color_gidue');
            echo _media($color->Image)->set('.imgfl')->width(155);
            echo '<br />'.$color->ProductColor;
            echo _close('div');
        }
    }
    ?>
</div>